﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class loopback_test : MonoBehaviour
{

	// Use this for initialization
	void Start ()
	{

	}
	float x = -100;
	int xdir=1;
	// Update is called once per frame
	void Update ()
	{
		if (move) {
			x += Time.deltaTime * 200*xdir;
			if (x > 0) {
				xdir = -1;
				x = 0;
			}
			if (x < -200) {
				xdir = 1;
				x = -200;
			}

			var loop = this.GetComponent<loopback> ();
			loop.height += Time.deltaTime * 200;
			loop.X = x;
		}
	}

	bool move = false;

	void OnGUI ()
	{
		if (GUILayout.Button ("SetLevels")) {
			var l1 = Resources.Load<GameObject> ("levels/l1_1");
			var l2 = Resources.Load<GameObject> ("levels/l1_2");
			var l3 = Resources.Load<GameObject> ("levels/l1_3");
			var loop = this.GetComponent<loopback> ();
			loop.srcs = new List<GameObject> { l1, l2, l3 };


		}
		if (GUILayout.Button ("move")) {
			move = true;
		}
		if (GUILayout.Button ("stop")) {
			move = false;
		}
	}
}
